<%@ page isELIgnored="false" language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fun" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<style type="text/css">
</style>
<script type="text/javascript">
	function addOrUpdateUser(){
		var r = $('#roleForm').form('validate');
		if(!r) {
			return false;
		}
		
	    if($('#roleid').val()!='')
	    {
			$.post("role/roleUpdate",$("#roleForm").serializeArray(),function(data){
				if(data.result == 'succ'){
					$('#MyPopWindow').window('close');
					$('#roleTable').datagrid('reload');  
					$.messager.alert('提示','保存成功','info');
				}else{
					if(data.reason == 'exists'){
						$.messager.alert('提示','已经存在','info');
					}else{
						$.messager.alert('提示','保存失败','info');
					}
				}
			});
	    }else
	    {
			$.post("role/roleAdd",$("#roleForm").serializeArray(),function(data){
				if(data.result == 'succ'){
					$('#MyPopWindow').window('close');
					$('#roleTable').datagrid('reload');  
					$.messager.alert('提示','保存成功','info');
				}else{
					if(data.reason == 'exists'){
						$.messager.alert('提示','已经存在','info');
					}else{
						$.messager.alert('提示','保存失败','info');
					}
				}
			});
	    }

	}
</script>
 	<form id="roleForm" method="post" style="margin: 10;text-align: center;">
 	<input type="hidden" name="roleid" id="roleid" value="${role.roleid }"/>
 	<input type="hidden" name="delflg" value="${role.delflg }"/>
 	<input type="hidden" name="creatuserid" value="${role.creatuserid }"/>
 	<input type="hidden" name="creatdatetime" value='<fmt:formatDate value="${role.creatdatetime }" pattern="yyyy-MM-dd HH:mm:ss"/>'/>
	<input type="hidden" name="version" value='${role.version }'/>
	<input type="hidden" name="enable" value='${role.enable }' />
	<table >
		<tr>
			<td>角色标识：</td>
			<td><input name="name" ${empty role.roleid ? "":"readonly='readonly'" } value='${role.name }' style="width: 200"
				 class="easyui-validatebox" validType="length[3,20]" required="true">
			</td>
		</tr>
		<tr>
			<td>角色描述：</td>
			<td><input type="text" name="descs" style="width: 200"
				class="easyui-validatebox" value="${role.descs }" required="true"></td>
		</tr>
	</table>
	<a href="#" id="btn-back" onclick="closeWindow();" class="easyui-linkbutton" iconCls="icon-back">返回</a>
	<a href="#" id="btn-add" onclick="addOrUpdateUser();" class="easyui-linkbutton" iconCls="icon-save">保存</a>
</form>